<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>修改管理员</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="./lib/layui/css/layui.css"  media="all">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script src="./js/jquery.min.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="L_id" class="layui-form-label">
                    <span class="x-red">*</span>id</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_id" name="id" required="" lay-verify="nikeid" readonly="readonly" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_role" class="layui-form-label">
                    <span class="x-red">*</span>权限</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_role" name="role" readonly="readonly" required="" lay-verify="nikerole" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>用户名</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_username" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_tele" class="layui-form-label">
                    <span class="x-red">*</span>电话</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_tele" name="tel" required="" lay-verify="tel" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">
                    <span class="x-red">*</span>密码</label>
                <div class="layui-input-inline">
                    <input type="password" id="L_pass" name="pass" required="" lay-verify="pass" autocomplete="off" class="layui-input"></div>
                <div class="layui-form-mid layui-word-aux">6到16个字符</div></div>
            <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="up" lay-submit="">修改</button></div>
        </form>
    </div>
</div>
<script>
    function GetQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  decodeURI(r[2]); return null;
    }
    $(function(){
        $("#L_username").val(GetQueryString('username'))
        $("#L_tele").val(GetQueryString('tele'))
        $("#L_id").val(GetQueryString('id'))
        $("#L_role").val(GetQueryString('role'))
    })
    layui.use(['form', 'layer','jquery'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        form.verify({
            nikename: function (value) {
                if (value.length < 1) {
                    return '用户名未填写';
                }
            },
            tel: [/^1\d{10}$/, '电话号码格式不正确'],
            pass: [/(.+){6,12}$/, '密码必须6到12位'],
        });
        form.on('submit(up)',
            function(data) {
                $.get("update.ao",data.field,function(result){
                    if(result==1){
                        layer.alert("修改成功", {
                                icon: 1
                            },
                            function() {
                                xadmin.close();
                                xadmin.father_reload();
                            });
                    }else{
                        layer.alert("修改失败", {
                                icon: 1
                            },
                            function() {
                                xadmin.close();
                                xadmin.father_reload();
                            });
                    }
                });
                return false;
            });
    })
</script>
</body>

</html>